<template>
  <div v-loading="loading">
    <el-form ref="form" :model="form" :rules="rules" label-width="120px" class="dataForm">
      <el-row>
        <el-col :span="12">
          <el-form-item :label="$t('机构名称')" prop="name">
            <el-input v-model="form.name" :placeholder="$t('机构名称')" show-word-limit maxlength="100" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('机构schema')" prop="dataSchema">
            <el-input v-model="form.dataSchema" :placeholder="$t('机构schema')" show-word-limit maxlength="100" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('环境')" prop="env">
            <el-input v-model="form.env" :placeholder="$t('环境')" show-word-limit maxlength="5" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item :label="$t('失败原因')" prop="failureReason">
            <template>
              <span v-html="form.failureReason" />
            </template>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer" style="text-align: right;">
      <!--保存 取消按钮-->
      <!-- <save-btn has-permi="system:word" /> -->
    </div>
  </div>
</template>

<script>
    import { getWordOnlineKeySyncRecord } from '@/api/system/word/wordOnlineKeySyncRecord'
    export default {
        data() {
            return {
                // 表单参数
                form: {},
                // 遮罩层
                loading: false,
                // 表单校验
                rules: {
                }
            }
        },
        created() {
        },
        methods: {
            // 初始化数据
            init(data) {
                this.loading = true
                if (data != null && data.id !== undefined) {
                    getWordOnlineKeySyncRecord(data.id).then(response => {
                        this.form = response.data
                        this.loading = false
                    }).catch(() => {
                      this.loading = false
                    })
                } else {
                    this.reset()
                    this.loading = false
                }
            },
            // 表单重置
            reset() {
                this.form = {
                    id: undefined,
                    keyId: undefined,
                    name: undefined,
                    schema: undefined,
                    env: undefined,
                    pushStatus: undefined,
                    failureReason: undefined,
                    remark: undefined,
                    createBy: undefined,
                    updateBy: undefined,
                    createTime: undefined,
                    updateTime: undefined,
                    delFlag: undefined
                }
                this.resetForm('form')
            },
            // 取消按钮
            cancel() {
                this.$parent.$parent.formOpen = false
                this.$parent.$parent.reset()
            },
            // 关闭form页面
            closeForm() {
                // 关闭form页面遮罩层
                this.loading = false
                // 关闭form页面
                if (this.$parent.$parent.formOpen !== undefined) {
                  this.$parent.$parent.formOpen = false
                }
                // 刷新list页面
                if (this.$parent.$parent.getList !== undefined) {
                  this.$parent.$parent.getList()
                }
            }
        }
    }
</script>
